<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of HomePage
 *
 * @author juwking
 */
class ClientPage extends PageController {

    function __construct() {
        parent::__construct();
    }

    function getPageName() {
        return 'client';
    }

    public function getTemplate() {
        return "client/client.tpl";
    }

    public function getSidebar() {
        $sidebar = array(
            array(label => 'Dodaj', link => ''),
            array(label => 'Wyswietl', link => 'showpage')
        );
        return $sidebar;
    }

    public function showpage() {
        $criteria = new Criteria();
        $criteria->add(ClientPeer::NAME, '%'.$_REQUEST['name'].'%',  Criteria::LIKE);
        $criteria->add(ClientPeer::SURNAME, '%'.$_REQUEST['surname'].'%',  Criteria::LIKE);

        $pager = new PropelPager($criteria, 'ClientPeer', 'doSelect', $page = 1, $rowsPerPage = 30);

        $this->assign('pages', $pager->getResult());
        $this->smarty->display('client/clientGrid.tpl');
    }

    public function nextPage() {
        $criteria = new Criteria();
        $pager = new PropelPager($criteria, 'ClientPeer', 'doSelect', $page = 1, $rowsPerPage = 30);

        $this->assign('pages', $pager->getResult());
        $this->smarty->display('client/clientGrid.tpl');
    }

    public function getPage() {
        return $this->page;
    }

    public function Previous() {

        $this->page--;
        $this->assign('pageNum', $this->page);
    }

}

?>
